home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Tools / Alpha 6.51b13 ƒ / Help / MacPerl.Specifics < prev    next >
Text File  |  1995-12-28  |  8KB  |  229 lines

  1. Specific features of MacPerl                    Matthias Neeracher 15Dec93
  2.  
  3. This file describes differences between MacPerl and a typical Unix perl
  4. implementation. Much of this information can also be found at the end of
  5. PerlHelp. If you have 411, search for Perl…Macintosh…Extensions.
  6.  
  7. 1. VARIA
  8.  
  9. "\n" on a Mac means ASCII 13, as opposed to Unix, where it means ASCII 10
  10.  
  11. Pathnames are specified as:
  12.  
  13. volume:folder:file                for absolute pathnames
  14. :folder:file                        for relative pathnames
  15. :file                                    for relative pathnames
  16. file                                    for relative pathnames
  17.  
  18. MacPerl has a limited capability to handle constructs like `command` or
  19. open(F, "|command"), if you are the lucky owner of ToolServer. Additionally, 
  20. whether you have toolserver or not, `pwd` and `Directory` (case is 
  21. significant) always return the current directory, followed by a newline.
  22.  
  23. 2. SOCKETS
  24.  
  25. MacPerl has more Socket families than Unix Perl. Additionally, there is a call
  26. choose() to allow the user to interactively specify addresses or file names. As
  27. there are lots of rather complicated data types, there is a library header 
  28. "GUSI.ph" which defines packing/unpacking procedures.
  29.  
  30. Choose() is called as follows:
  31.  
  32. &MacPerl'Choose(DOMAIN,TYPE,PROMPT,CONSTRAINT,FLAGS,DEFAULT)
  33. &MacPerl'Choose(DOMAIN,TYPE,PROMPT,CONSTRAINT,FLAGS)
  34. &MacPerl'Choose(DOMAIN,TYPE,PROMPT,CONSTRAINT)
  35. &MacPerl'Choose(DOMAIN,TYPE,PROMPT)
  36.          Puts up a modal dialog prompting the user to choose an address. 
  37.          DOMAIN specifies the communication domain, like for socket().
  38.          TYPE may be used by future communication domains to further 
  39.          differentiate within a domain, but is ignored by current domains. 
  40.          PROMPT is a message that will appear in the dialog. CONSTRAINT may 
  41.          be set to a suitable packed value to restrict the types of acceptable
  42.          addresses.
  43.  
  44.          Examples:
  45.  
  46.          require "GUSI.ph";
  47.          
  48.          $file = 
  49.             MacPerl'Choose(
  50.                &GUSI'AF_FILE, 0, "", 
  51.                &GUSI'pack_sa_constr_file("OBJ ", "TEXT"));
  52.                             
  53.                             Return the full pathname of an existing text
  54.                             or MPW object file.
  55.          
  56.          $dir = &MacPerl'Choose(&GUSI'AF_FILE, 0, "", "", &GUSI'CHOOSE_DIR);
  57.  
  58.                             Return the full pathname of an existing directory.
  59.                             
  60.          $file = 
  61.             &MacPerl'Choose(
  62.                &GUSI'AF_FILE, 0, "", "", 
  63.                &GUSI'CHOOSE_NEW + &GUSI'CHOOSE_DEFAULT, "yo");
  64.  
  65.                             Return the pathname of a new file to be created.
  66.                                      
  67. Socket families are:
  68.  
  69. Internet:
  70.  
  71. Packing addresses:    &GUSI'pack_sockaddr_in(family, address, port)
  72. Unpacking addresses:    (family, address, port) = &GUSI'unpack_sockaddr_in(addr)
  73. Choose:                    Not available.
  74.  
  75. Unix:
  76.  
  77. Packing addresses:    &GUSI'pack_sockaddr_un(family, path)
  78. Unpacking addresses:    (family, path) = &GUSI'unpack_sockaddr_un(addr)
  79. Choose:                    choose(&GUSI'AF_UNIX, 0, "", "", 0, "");
  80.                             looks up an existing address.
  81.                             choose(
  82.                                 &GUSI'AF_UNIX, 0, "Yes ?", "", 
  83.                                 &GUSI'CHOOSE_NEW + &GUSI'CHOOSE_DEFAULT, "yo");
  84.                             creates a new address.
  85.                             No constraints may be specified.
  86.  
  87. Appletalk (ADSP):
  88.  
  89. Packing addresses:    &GUSI'pack_sockaddr_atlk(family, net, node, socket)     (numerical)
  90.                             &GUSI'pack_sockaddr_atlk_sym(family, obj, type, zone)    (symbolic)
  91. Unpacking addresses:    (family, net, node, socket) = &GUSI'unpack_sockaddr_atlk(addr)
  92.                             (family, obj, type, zone) = &GUSI'unpack_sockaddr_atlk_sym(addr)
  93. Choose:                    choose(&GUSI'AF_APPLETALK, 0, "Eh ?", 
  94.                                 &GUSI'pack_sa_constr_atlk("LaserWriter", "GorillaWriter"),
  95.                                 0, "");
  96.                             looks up an existing address.
  97.                             New addresses may not currently be created with choose.
  98.  
  99. PPC Toolbox:
  100.  
  101. Packing addresses:    &GUSI'pack_sockaddr_ppc(family, type, name, porttype)
  102. Unpacking addresses:    Not available.
  103. Choose:                    choose(&GUSI'AF_PPC, 0, "Eh ?", 
  104.                                 &GUSI'pack_sa_constr_ppc("Gonkulator"), 0, "");
  105.                             looks up an existing address.
  106.                             New addresses may not currently be created with choose.
  107.  
  108.  
  109. 3. ADDITIONAL FUNCTIONS AVAILABLE IN MACPERL
  110.  
  111. &MacPerl'Answer(PROMPT)
  112. &MacPerl'Answer(PROMPT,BUTTON1)
  113. &MacPerl'Answer(PROMPT,BUTTON1,BUTTON2)
  114. &MacPerl'Answer(PROMPT,BUTTON1,BUTTON2,BUTTON3)
  115.           Presents to the user a dialog with 1, 2, or 3 buttons. 
  116.           
  117.           Examples:
  118.           
  119.           &MacPerl'Answer("Nunc et in hora mortis nostrae", "Amen");
  120.                               
  121.                             always returns 0.
  122.                             
  123.           &MacPerl'Answer("I refuse");
  124.           
  125.                               is equivalent to &MacPerl'Answer("I refuse", "OK");
  126.           
  127.           &MacPerl'Answer("Delete hard disk ?", "OK", "Cancel");
  128.                   
  129.                             returns 1 for OK, 0 for Cancel
  130.         
  131.           &MacPerl'Answer("Overwrite existig file", "Overwrite", "Skip", "Cancel");
  132.               
  133.                             returns 2 for Overwrite, 1 for Skip, 0 for Cancel
  134.                                      
  135. &MacPerl'Ask(PROMPT, DEFAULT)
  136. &MacPerl'Ask(PROMPT)
  137.           Asks the user for a string. A default value may be given. Returns
  138.           undef if the dialog is cancelled.
  139.           
  140.           Example:
  141.           
  142.           $phone = &&MacPerl'Ask("Enter your phone number:");
  143.           $name = &&MacPerl'Ask("Enter your first name", "Bruce");
  144.           
  145.                             Useful for Australian database applications
  146.                                      
  147. &MacPerl'Pick(PROMPT, VALUES)
  148.           Asks the user to pick a choice from a list. VALUES is a list of choices. 
  149.           Returns undef if the dialog is cancelled.
  150.           
  151.           Examples:
  152.           
  153.           $color = &MacPerl'Pick("What's your favorite color baby ?", "Red", "Green", "Gold");
  154.              
  155. &MacPerl'SetFileInfo(CREATOR,TYPE,FILE...)
  156.             Changes the file types and creators of the file(s).
  157.  
  158.             Examples:
  159.  
  160.             &MacPerl'SetFileInfo("MPS ", "TEXT", yin, yang);
  161.  
  162.                                     Turn yin and yang into MPW text files
  163.  
  164. &MacPerl'GetFileInfo(FILE)
  165.             In scalar context, returns the file type. In array context, returns
  166.             (creator,type).
  167.  
  168.             Examples:
  169.  
  170.             &MacPerl'GetFileInfo(yin);
  171.  
  172.                                     Returns "TEXT" or ("MPS ", "TEXT").
  173.  
  174. &MacPerl'DoAppleScript(SCRIPT)
  175.             Execute an AppleScript script.
  176.             
  177.             Example:
  178.             
  179.             &MacPerl'DoAppleScript(<<END_SCRIPT);
  180.          tell application "MacPerl"
  181.           make new Window
  182.           copy "Inserting text the hard way." to character 1 of front Window
  183.             end tell
  184.             END_SCRIPT
  185.  
  186. &MacPerl'Reply(ANSWER)
  187.             Reply to current DoScript request. Useful if you are calling Perl 
  188.             scripts from other applications.
  189.             
  190. &MacPerl'Quit(LEVEL)
  191.             If Level is 0, don't quit after ending the script. If 1, quit if 
  192.             running under a runtime version, if 2, always quit.
  193.  
  194. &MacPerl'LoadExternals(LIBFILE)
  195.             Load XCMD and XFCN extensions contained in file LIBFILE, which is searched
  196.             along the same path as it would be for a require. The extensions are made
  197.             accessible in the current package, unless they conatin an explicit package
  198.             name.
  199.  
  200. &MacPerl'DebugExternals(DEBUGLEVEL)
  201.             If DEBUGLEVEL is 0, don't print any debug information for XCMDs and XFCNs. 
  202.             If 1, print information for unimplemented callbacks. If 2, print 
  203.             informations for all callbacks.
  204.  
  205. &MacPerl'FAccess(FILE, CMD, ARGS)
  206.             When called from the tool, manipulate various information of files. To 
  207.             get the command constants, it's convenient to require "FAccess.ph".
  208.  
  209.     $TAB = &MacPerl'FAccess(FILE, &F_GTABINFO)
  210.     &MacPerl'FAccess(FILE, &F_STABINFO, TAB)
  211.             Manipulate tabulator setting (in spaces per tab).
  212.             
  213.     ($FONTNAME, $FONTSIZE) = &MacPerl'FAccess(FILE, &F_GFONTINFO)
  214.     $FONTNUM = &MacPerl'FAccess(FILE, &F_GFONTINFO)
  215.     &MacPerl'FAccess(FILE, &F_SFONTINFO, FONT [, SIZE])
  216.             Manipulate font and size information. Both font names and font numbers
  217.             are accepted for F_SFONTINFO; F_GFONTINFO returns a font name in an
  218.             array context, a font number in a scalar context.
  219.             
  220.     ($STARTSEL, $ENDSEL, $DISPLAYTOP) = &MacPerl'FAccess(FILE, &F_GSELINFO)
  221.     $STARTSEL = &MacPerl'FAccess(FILE, &F_GSELINFO)
  222.     &MacPerl'FAccess(FILE, &F_SSELINFO, $STARTSEL, $ENDSEL [, $DISPLAYTOP])
  223.             Manipulate the MPW selection of a file.
  224.             
  225.     ($LEFT, $TOP, $RIGHT, $BOTTOM) = &MacPerl'FAccess(FILE, &F_GWININFO)
  226.     $TOP = &MacPerl'FAccess(FILE, &F_GWININFO)
  227.     &MacPerl'FAccess(FILE, &F_SWININFO, LEFT, TOP [, RIGHT, BOTTOM])
  228.             Manipulate the window position.
  229.